import myRequest from './index';

export const getFactoryListApi = (data: any) => {
  return myRequest<any>('/admin_api/factory/list', {
    method: 'POST',
    data,
  });
};

export const getFactoryCategoryApi = (data: any) => {
  return myRequest<any>('/admin_api/factory_category/list', {
    method: 'POST',
    data,
  });
};

export const getFactoryVehicleApi = (data: any) => {
  return myRequest<any>('/admin_api/factory_vehicle_type/list', {
    method: 'POST',
    data,
  });
};

export const changeFactoryStatusApi = (data: { ids: string; status: number }) => {
  const formData = new FormData();
  formData.append('ids', data.ids);
  formData.append('status', data.status.toString());
  return myRequest<any>('/admin_api/factory/change_status', {
    method: 'POST',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data; boundary=----',
    },
  });
};

export const getFactoryLocationApi = (data: { ids: string }) => {
  const formData = new FormData();
  formData.append('ids', data.ids);
  return myRequest<any>('/admin_api/factory/batch_update_location', {
    method: 'POST',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data; boundary=----',
    },
  });
};

export const getFactoryImageApi = (data: { ids: string }) => {
  const formData = new FormData();
  formData.append('ids', data.ids);
  return myRequest<any>('/admin_api/factory/batch_update_picture', {
    method: 'POST',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data; boundary=----',
    },
  });
};

export const editFactoryApi = (data: FormData) => {
  return myRequest<any>('/admin_api/factory/add_or_update', {
    method: 'POST',
    data,
    headers: {
      'Content-Type': 'multipart/form-data; boundary=----',
    },
  });
};

export const addFactoryApi = (data: FormData) => {
  return myRequest<any>('/admin_api/factory/add_or_update', {
    method: 'POST',
    data,
    headers: {
      'Content-Type': 'multipart/form-data; boundary=----',
    },
  });
};
